<?php

namespace app\admin\model;

class OauthFocus extends \app\common\model\OauthFocus
{
    /**
     * 列表
     * @param $where
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public static function getList($where)
    {
        $sql = static::field('o.id, o.nickname, f.create_time')
            ->alias('f')
            ->join('oauth o', 'f.focus_id = o.id');

        if ($where) {
            $sql->where($where);
        }

        $model = $sql->paginate(null, false, ['query' => request()->param()])->each(function ($item, $key) {
            $item['create_time'] = get_datetime($item['create_time']);
            return $item;
        });

        // 获取总记录数
        $count = $model->total();
        return [
            'model' => $model,
            'count' => $count
        ];
    }
}